#include "StdAfx.h"
#include "RoundCamera.h"


RoundCamera::RoundCamera(Ogre::SceneManager* scm,float h, float r, Ogre::Vector3 pos, Ogre::String target)
{
	TimeCounter=0;
	height = h;
	radius = r;
	position = pos;

	camera = scm->createCamera("roundCam");
	targetNode = scm->getEntity(target)->getParentSceneNode();
	camera->lookAt(targetNode->getPosition());

}


RoundCamera::~RoundCamera(void)
{
}

void RoundCamera::Step(float TimeSinceLastEvent)
{
	TimeCounter+=TimeSinceLastEvent;

	float x = targetNode->getPosition().x+position.x+radius* cos(TimeCounter);
	float z = targetNode->getPosition().z+position.z+radius* sin(TimeCounter);

	camera->setPosition(x,targetNode->getPosition().y+height,z);
	camera->lookAt(targetNode->getPosition());
	camera->setNearClipDistance(1);
}

Ogre::Camera * RoundCamera::getCamera()
{
	return camera;
}